package StudyCode.summary.mydatetime;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class AgeFromLocalDate {

	public static void main(String[] args) {
		LocalDate ldt = LocalDate.of(1991, 1, 1);
		LocalDate ldt1 = LocalDate.of(2000, 1, 1);
		System.out.println(ldt.toString() + "出生的今年" + getAge(ldt));
		System.out.println(ldt1.toString() + "出生的今年" + getAge(ldt1));
	}

	private static long getAge(LocalDate date) {
		return ChronoUnit.YEARS.between(date, LocalDate.now());
	}
}
